export function seconds2time(seconds, format = 'hh:mm:ss') {
    const hh = String(Math.floor(seconds / 3600));
    const mm = String(Math.floor((seconds % 3600) / 60));
    const ss = String(seconds % 60);
    const pad = (v) => v.padStart(2, '0');
    return format.replace(/HH/gi, pad(hh)).replace(/H/gi, hh).replace('mm', pad(mm)).replace('m', mm).replace('ss', pad(ss)).replace('s', ss);
}
export function time2seconds(time, format = 'hh:mm:ss') {
    const parts = format.split(':');
    const values = time.split(':');
    let hours = 0, minutes = 0, seconds = 0;
    parts.forEach((part, index) => {
        if (part === 'hh') {
            hours = Number(values[index]);
        }
        else if (part === 'mm') {
            minutes = Number(values[index]);
        }
        else if (part === 'ss') {
            seconds = Number(values[index]);
        }
    });
    return hours * 3600 + minutes * 60 + seconds;
}
export function coverFileSize(size) {
    const units = ['B', 'KB', 'MB', 'GB', 'TB'];
    let i = 0;
    while (size >= 1024 && i < units.length - 1) {
        size /= 1024;
        i++;
    }
    return `${Math.round(size * 100) / 100} ${units[i]}`;
}
